#include "head.h"
#include <stdio.h>
#include <sys/epoll.h>

int init_tcp(int* socket_fd,char* port,char* ip){

    *socket_fd = socket(AF_INET,SOCK_STREAM,0);

    struct sockaddr_in sockaddr;
    sockaddr.sin_family = AF_INET;
    sockaddr.sin_port = htons(atoi(port));
    sockaddr.sin_addr.s_addr = inet_addr(ip);
 
    int ret_conn = connect(*socket_fd,(struct sockaddr*)&sockaddr,sizeof(sockaddr));
    ERROR_CHECK(ret_conn,-1,"connection");

    return 0;
}

int add_to_epoll(int epoll_fd,int fd){

    struct epoll_event event;
    event.data.fd = fd;
    event.events = EPOLLIN;
    epoll_ctl(epoll_fd,EPOLL_CTL_ADD,fd,&event);

    return 0;
}

void user_system(int socket_fd){

    printf("(1)register (2)login (3)exit\n");
    int choice;
    scanf("choose : %d",&choice);
    send(socket_fd,&choice,sizeof(int),MSG_WAITALL);

    if(choice == 1){
       
    }
}




















